package com.bkgy.modular.configureRules.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bkgy.modular.configureRules.dto.ThicknessGrading1720Dto;
import com.bkgy.modular.configureRules.entity.ThicknessGrading1720;
import com.bkgy.modular.configureRules.mapper.ThicknessGrading1720Mapper;
import com.bkgy.modular.configureRules.service.ThicknessGrading1720Service;
import com.bkgy.sys.common.entity.ResultData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author
 * @version 1.0
 * @ClassName ThicknessGrading1720ServiceImpl
 * @date 2023/4/19 10:22
 */
@Service
public class ThicknessGrading1720ServiceImpl extends ServiceImpl<ThicknessGrading1720Mapper, ThicknessGrading1720> implements ThicknessGrading1720Service {

    @Resource
    private ThicknessGrading1720Mapper mapper;

    @Override
    public ResultData queryThicknessConfiguration1720() {
        List<ThicknessGrading1720> thicknessGrading1720s = mapper.selectList(null);
        return ResultData.ResultDataFaultSelf("操作成功",thicknessGrading1720s);
    }

    @Override
    public ResultData updateThicknessConfiguration1720(ThicknessGrading1720Dto dto) {
        Double classid = dto.getClassid();
        Double ora_thk_class = dto.getOra_thk_class();
        Double pro_thk_class = dto.getPro_thk_class();
        Double wid_class = dto.getWid_class();
        Double yield_class = dto.getYeild_class();
        Double yp_class = dto.getYp_class();
        if (classid == null) {
            return ResultData.ResultDataFaultSelf("参数有误,请检查参数",-1);
        }
        LambdaQueryWrapper<ThicknessGrading1720> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ThicknessGrading1720::getClassid,classid);
        ThicknessGrading1720 thicknessGrading1720 = mapper.selectOne(queryWrapper);
        thicknessGrading1720.setOra_thk_class(ora_thk_class);
        thicknessGrading1720.setPro_thk_class(pro_thk_class);
        thicknessGrading1720.setWid_class(wid_class);
        thicknessGrading1720.setYeild_class(yield_class);
        thicknessGrading1720.setYp_class(yp_class);
        int flag = mapper.update(thicknessGrading1720, queryWrapper);
        return ResultData.ResultDataFaultSelf("修改状态",flag);
    }
}
